package com.ny.demo0428;

class CarInsurance extends Insurance {
    private double carValue;  // 汽车价值
    private int accidentCount; // 事故次数

    public CarInsurance(double carValue, int accidentCount) {
        this.carValue = carValue;
        this.accidentCount = accidentCount;
    }

    @Override
    public double calculatePremium() {
        double basePremium = carValue * 0.02; // 基础保费（2%）
        if (accidentCount == 0) {
            return basePremium;
        } else if (accidentCount == 1) {
            return basePremium * 1.1; // 增加10%
        } else {
            return basePremium * 1.2; // 增加20%
        }
    }
}